from tkinter import *
from Dmjdm import Dmwin

dmwin = Dmwin()
islink = False
def dmlink():
    global islink
    if islink:
        linkBTtext.set("连接")
        dmwin.winend()
        islink = False
    else:
        linkBTtext.set("断开")
        islink = True
        dmwin.ready(roomid=roomidSB.get(),textsize=textsizeSB.get(),sizey=sizehSB.get(),sizex=sizewSB.get(),textcl=textclSB.get())
        dmwin.isend = True
        dmwin.winrun()

def dmlock():
    dmwin.winlock()

root=Tk()
root.title('弹幕姬')
linkBTtext = StringVar()
roomidv=StringVar()
textsizev=StringVar()
sizewv=StringVar()
sizehv=StringVar()
textclv=StringVar()
fral = Frame(root)
fral0 = Frame(fral)
fral1 = Frame(fral)
fral2 = Frame(fral)
roomidSB = Spinbox (fral0,from_ = 0,to = 9999999999,increment = 1,textvariable=roomidv)
roomidv.set(47631)
textsizeSB = Spinbox (fral0,from_ = 0,to = 9999999999,increment = 1,textvariable=textsizev)
textsizev.set(20)
sizewSB = Spinbox (fral1,from_ = 0,to = 9999999999,increment = 1,textvariable=sizewv)
sizewv.set(400)
sizehSB = Spinbox (fral1,from_ = 0,to = 9999999999,increment = 1,textvariable=sizehv)
sizehv.set(600)
textclSB = Spinbox (fral2,textvariable=textclv,values = ('white','pink','skyblue','black'))
textclv.set('white')
roomidLB = Label(fral0, text='房间号：')
textsizeLB = Label(fral0, text='字体大小')
sizewLB = Label(fral1, text='区域大小')
sizehLB = Label(fral1, text='     X     ')
textclLB = Label(fral2, text='字体颜色')
linkBT = Button(fral, textvariable=linkBTtext,height=4,command=dmlink)
linkBTtext.set("连接")
lockBT = Button(fral, text='锁定',height=4,command=dmlock)
fral.pack(padx=0, pady=0, side=TOP)
fral0.pack()
roomidLB.pack(padx=0, pady=0, side=LEFT)
roomidSB.pack(padx=0, pady=0, side=LEFT)
textsizeLB.pack(padx=0, pady=0, side=LEFT)
textsizeSB.pack(padx=0, pady=0, side=LEFT)
fral1.pack()
sizewLB.pack(padx=0, pady=0, side=LEFT)
sizewSB.pack(padx=0, pady=0, side=LEFT)
sizehLB.pack(padx=0, pady=0, side=LEFT)
sizehSB.pack(padx=0, pady=0, side=LEFT)
fral2.pack()
textclLB.pack(padx=0, pady=0, side=LEFT)
textclSB.pack(padx=0, pady=0, side=LEFT)
linkBT.pack(fill = X)
lockBT.pack(fill = X)
root.mainloop()
dmwin.isend = False
